package com.moqianfan.mcuassistant.comm;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.moqianfan.mcuassistant.database.DaoMaster;
import com.moqianfan.mcuassistant.database.McuOrderDao;
import com.moqianfan.mcuassistant.utils.LogUtil;

import org.greenrobot.greendao.database.Database;

/**
 * Created by limh on 2017/8/17.
 * 数据库升级
 */

class MyDaoHelper extends DaoMaster.DevOpenHelper {

    private String TAG = "MyDaoHelper";

    MyDaoHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        if (oldVersion != newVersion) {
            LogUtil.d(TAG, "升级数据库");
            if (newVersion == 2) {
                McuOrderDao.createTable(db, true);
            }
        }
    }
}
